﻿using System;

using SBPweb.MediaCenter.Common.Modularity;

namespace SBPweb.MediaCenter.Common.Communication
{
    public abstract class MessageBase : IMessage
    {

        public static string BASE_FORMAT = "From: {0} - {1}";

        #region Protected fields

        protected string pText;
        protected string pFormat = BASE_FORMAT;
        protected IModule pSender;

        #endregion

        #region Constructor logic

        protected MessageBase(IModule sender, string text)
        {
            pSender = sender;
            pText = text;
        }

        #endregion

        #region Public property accessors

        public string Text
        {
            get
            {
                return pText;
            }
        }

        public string Format
        {
            get
            {
                return pFormat;
            }
            protected set
            {
                pFormat = value;
            }
        }

        public IModule Sender
        {
            get
            {
                return pSender;
            }
        }

        #endregion

        #region Methods

        public override string ToString()
        {
            return string.Format(pFormat, pSender.Name, pText);
        }

        #endregion
    }
}